/*
 * @Author: pq yxqxq79@gmail.com
 * @Date: 2025-06-20 15:12:57
 * @LastEditors: pq yxqxq79@gmail.com
 * @LastEditTime: 2025-06-20 15:30:21
 * @FilePath: \order2-h5d:\小花\rcs-h5\src\main.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";
import "lib-flexible"; //rem转换器
import "@/assets/main.scss";
// import '@/assets/font/font.css'
import VueI18n from "vue-i18n";
import Vant from "vant";
import "vant/lib/index.css";
import ElementUI from "element-ui";
import "element-ui/lib/theme-chalk/index.css";
import "element-ui/lib/theme-chalk/index.css";
// import VideoPlayer from "vue-video-player";
// import "vue-video-player/src/custom-theme.css";
// import "video.js/dist/video-js.css";

/**
 * 拷贝插件
 */
import VueClipboard from "vue-clipboard2";
Vue.use(VueClipboard);

import zh from "./assets/lang/zh";
import en from "./assets/lang/en";
import ja from "./assets/lang/ja";
import ko from "./assets/lang/ko";
import ru from "./assets/lang/ru";

// Vue.use(VideoPlayer);
Vue.use(ElementUI);
Vue.use(Vant);

Vue.use(VueI18n);
const messages = {
  zh: zh,
  en: en,
  ja: ja,
  ko: ko,
  ru: ru,
};
const i18n = new VueI18n({
  locale: localStorage.getItem("locale") || store.state.locale, // 首先从 localStorage 获取语言，如果没有则使用 Vuex 的语言
  messages,
});

const Base64 = require("js-base64").Base64;

Vue.filter("formatNumber", function(value) {
  // 检查 value 是否为 undefined 或 null
  if (!value) {
    return 0; // 或返回其他默认值
  }

  // 将 value 转换为数字
  const num = parseFloat(value);

  // 检查是否为整数
  if (Number.isInteger(num)) {
    return num.toString(); // 如果是整数，直接返回字符串
  } else {
    // 使用 toFixed 处理小数，并确保不以科学计数法显示
    return num.toLocaleString("en-US", {
      minimumFractionDigits: 4,
      maximumFractionDigits: 4,
    });
  }
});

Vue.config.productionTip = false;
new Vue({
  router,
  store,
  i18n,
  Base64,
  render: (h) => h(App),
}).$mount("#app");
